package com.example.hellomap.rest;

import org.junit.Test;

import junit.framework.TestCase;

public class test_events extends TestCase {
	@Test
	public void test_events_normal_get() {
		ServerInterface.get("events");
		ServerInterface.get("events/001");
		ServerInterface.get("events/Valami");
		ServerInterface.get("events/near/47.001-19.1102");
		ServerInterface.get("events/near/47.001-19.1102-100");
		ServerInterface.get("events/near/47.001-19.1102-80000");
	}
		
	@Test
	public void test_events_caseInsensitive_get() {
		ServerInterface.get("events/vaLAMi");
	}
	
	@Test
	public void test_events_doesNotExist_get() {
		ServerInterface.get("events/elemerce");
	}
	
	//POST
	@Test
	public void test_events_normal_post() {
		events event = new events("002", "Korcsolya", "2014-08-08T11:00:00.000Z", "2014-08-08T14:00:00.000Z", "Varosliget");
		ServerInterface.post("events", event);
		
		events event2 = new events();
		event2.setId("Bill");
		ServerInterface.post("events", event2);
		ServerInterface.get("events");
	}
	
	@Test
	public void test_events_ShouldBeDuplicateUsernameError() {
		events event = new events("002", "Tesztesemeny", "2014-08-08T11:00:00.000Z", "2014-08-08T14:00:00.000Z", "Varosliget");
		ServerInterface.post("events", event);
		ServerInterface.post("events", event);
		ServerInterface.get("events");
	}
	
	@Test
	public void test_events_NotExistingCollectionError() {
		events event = new events("002", "Tesztesemeny", "2014-08-08T11:00:00.000Z", "2014-08-08T14:00:00.000Z", "Varosliget");
		ServerInterface.post("collection", event);
	}
	
	@Test
	public void test_events_NotExistingIdPostError() {
		events event = new events();
		ServerInterface.post("events", event);
		//ServerInterface.get("events");
	}
	
	//DELETE
	@Test
	public void test_events_normal_delete() {
		ServerInterface.delete("events", "esid");
	}

	public void test_events_DoesNotExist_delete() {
		ServerInterface.delete("events", "Geza");
	}

	public void test_DoesNotExist_collection_delete() {
		ServerInterface.delete("felhasznalok", "Geza");
	}

	//PUT
	public void test_events_normal_putPlace() {
		ServerInterface.updateEvent("002", "Nagytevel", "place");
	}
	public void test_events_normal_putDate() {
		ServerInterface.updateEvent("002", "2014-08-08T13:30:00.000Z", "to");
	}

	public void test_events_normal_putName() {
		ServerInterface.updateEvent("002", "Jégkorcsolya", "name");
	}
	
	
	public void test_events_notExisting_putNameError() {
		ServerInterface.updateUser("dob", "dob", "name");
	}

  public void test_events_notHavePermissionError() {
		ServerInterface.updateUser("002", "dob", "_id");
	}

}
